<?php
/**
 * Created by PhpStorm.
 * Script Name: HandlerLoginCode.php
 * Create: 3/19/22 10:59 PM
 * Description: 返回登录码
 * Author: fudaoji<fdj@kuryun.cn>
 */

namespace plugin\wechat\app\bot\handler;

use app\common\service\Tenant as TenantService;
use plugin\wechat\app\service\BotAddon;

class HandlerConnected extends Handler
{
    public function handle(){
        $this->basic();
        $this->addon();
    }

    public function basic(){

    }

    protected function addon()
    {
        $apps = TenantService::getCompanyActiveApps(TenantService::getCompanyById($this->bot['company_id']), [['name','<>', 'wechat']]);
        foreach ($apps as $k => $v){
            $class_name = '\\plugin\\'.$v['name'].'\\app\\platform\\controller\\Bot';
            if(class_exists($class_name)){
                $class = new $class_name();
                if(method_exists($class, 'loginHandle')){
                    $class->loginHandle();
                }
            }
        }
    }
}